****use data


*cap cd "/Users/*PATH*/

log using "Replication_Appendix.log", replace


***************************
******************************************
*******************APPENDIX**************
***************************************
***************************

use "officers_replication", clear


replace voteimp_w1=.  if  voteimp_w1 ==99
replace voteimp_w2=.  if  voteimp_w2 ==99
replace voteimp_w3=.  if  voteimp_w3 ==99

gen d_voteimp_may=voteimp_w2-voteimp_w1
gen d_voteimp_nov=voteimp_w3-voteimp_w1

replace voteduty_w1=. if voteduty_w1 ==99
replace voteduty_w2=. if voteduty_w2 ==99
replace voteduty_w3=. if voteduty_w3 ==99

gen d_voteduty_may=voteduty_w2-voteduty_w1
gen d_voteduty_nov=voteduty_w3-voteduty_w1

replace cleanelections_w1=.  if  cleanelections_w1==99
replace cleanelections_w2=.  if  cleanelections_w2==99
replace cleanelections_w3=.  if  cleanelections_w3==99

gen d_cleanelections_may=cleanelections_w2-cleanelections_w1
gen d_cleanelections_nov=cleanelections_w3-cleanelections_w1

replace trustparties_w1=. if  trustparties_w1==99
replace trustparties_w2=. if  trustparties_w2==99
replace trustparties_w3=. if  trustparties_w3==99

gen d_trustparties_may=trustparties_w2-trustparties_w1
gen d_trustparties_nov=trustparties_w3-trustparties_w1

replace  freedomideas_w1=. if freedomideas_w1==99
replace  freedomideas_w2=. if freedomideas_w2==99
replace  freedomideas_w3=. if freedomideas_w3==99

gen d_freedomideas_may=freedomideas_w2-freedomideas_w1
gen d_freedomideas_nov=freedomideas_w3-freedomideas_w1

replace citizensimp_w1=. if citizensimp_w1==99
replace citizensimp_w2=. if citizensimp_w2==99
replace citizensimp_w3=. if citizensimp_w3==99

gen d_citizensimp_may=citizensimp_w2-citizensimp_w1
gen d_citizensimp_nov=citizensimp_w3-citizensimp_w1

replace votenotimp_w1=. if votenotimp_w1==99
replace votenotimp_w2=. if votenotimp_w2==99
replace votenotimp_w3=. if votenotimp_w3==99

gen d_votenotimp_may=votenotimp_w2-votenotimp_w1
gen d_votenotimp_nov=votenotimp_w3-votenotimp_w1

replace corruption_w1=. if   corruption_w1==99
replace corruption_w2=. if    corruption_w2==99
replace corruption_w3=. if    corruption_w3==99

gen d_corruption_may= corruption_w2-corruption_w1
gen d_corruption_nov= corruption_w3-corruption_w1

replace dontunderstandpolitics_w1=. if   dontunderstandpolitics_w1==99
replace dontunderstandpolitics_w2=. if    dontunderstandpolitics_w2==99
replace dontunderstandpolitics_w3=. if    dontunderstandpolitics_w3==99

gen d_dontunderstandpolitics_may=dontunderstandpolitics_w2-dontunderstandpolitics_w1
gen d_dontunderstandpolitics_nov=dontunderstandpolitics_w3-dontunderstandpolitics_w1

replace demonotworking_w1=. if   demonotworking_w1==99
replace demonotworking_w2=. if    demonotworking_w2==99
replace demonotworking_w3=. if    demonotworking_w3==99

gen d_demonotworking_may=demonotworking_w2-demonotworking_w1
gen d_demonotworking_nov=demonotworking_w3-demonotworking_w1

replace systnotworried_w1=. if    systnotworried_w1==99
replace systnotworried_w2=. if    systnotworried_w2==99
replace systnotworried_w3=. if    systnotworried_w3==99

gen d_systnotworried_may=systnotworried_w2-systnotworried_w1
gen d_systnotworried_nov=systnotworried_w3-systnotworried_w1



*******************************
* A.1. DESCRIPTIVES
***************************

*Summary statistics

**We use the Wave 2 sample that we use in the analyses

eststo: logit  vote_may  treatment  female age low_education high_educat i.employmentstatus  , 
gen sample_may=1 if e(sample)


sum treatment   vote_2016 vote_april vote_may vote_nov female age low_educ med_ed high_ed ///
 employed retired unemployed student housechores ideology if sample_m==1


  
*A.2 T-TEST 

ttest vote_2016, by(treatment)
ttest vote_april, by( treatment)
ttest vote_may, by(treatment)
ttest vote_nov, by( treatment)



**********
*BALANCE : REGRESION
***********


eststo clear
eststo: logit treatment  vote_2016  ideology low_educ high_educ   voteimp_w1  voteduty_w1  cleanelections_w1 trustparties_w1  votenotimp_w1 citizensimp_w1   freedomideas_w1  corruption_w1 dontunderstandpolitics_w1 demonotworking_w1  systnotworried_w1 

esttab using Balance.tex, label  ///
   title(Balance) replace se

   
***************
*ATTTRITION
*****************


gen attrition1=.
replace attrition1=0 if wave1==1 & wave2_w2==1
replace attrition1=1 if wave1==1 & wave2_w2==.

gen attrition2=.
replace attrition2=1 if wave2_w2==1 & wave3_w3==.
replace attrition2=0 if wave2_w2==1 & wave3_w3==1



eststo clear


eststo: reg attrition1 female age low_ed high_ed  i.employmentstatus vote_2016  ideology  i.region

eststo: reg attrition2 female age  low_ed  high_ed   i.employmentstatus vote_2016  ideology  i.region
 
 esttab using Attrition.tex, label  ///
   title(Attriton) replace se



   
************************
*******FULL TABLES
************************

eststo clear

eststo: logit  vote_2016 treatment  female age low_education high_educat i.employmentstatus  
eststo: logit  vote_april  treatment  female age low_education high_educat i.employmentstatus  , 
eststo: logit   vote_may  treatment  female age low_education high_educat i.employmentstatus  , 
eststo: logit   vote_nov  treatment  female age low_education high_educat i.employmentstatus  
 gen last_sample=1 if e(sample)
esttab using Fullmodels.tex, label  ///
   title(Full models) replace se

   
*Only for November sample

eststo clear

eststo: logit  vote_2016 treatment  female age low_education high_educat i.employmentstatus  if last_sample==1
eststo: logit  vote_april  treatment  female age low_education high_educat i.employmentstatus   if last_sample==1 , 
eststo: logit   vote_may  treatment  female age low_education high_educat i.employmentstatus   if last_sample==1, 
eststo: logit   vote_nov  treatment  female age low_education high_educat i.employmentstatus   if last_sample==1
esttab using Fullmodels2.tex, label  ///
   title(Full models with Novemmber 2019 sample) replace se

   
   
   
************************ 
* SOFT TREATMENT
************************

*MODELS WITHOUT COVARIATES

logit  vote_2016 replacement , 
margins, dydx( replacement) post
estimates store s1


logit  vote_ap    replacement , 
margins, dydx(  replacement ) post
estimates store s2


logit   vote_may    replacement , 
margins, dydx(   replacement ) post
estimates store s3



logit   vote_nov   replacement , 
margins, dydx( replacement) post
estimates store s4


coefplot (s1 , label( "Turnout 2016 (Placebo)")) ( s2, label( "Turnout April 2019")) ///
 ( s3, label( "Turnout May 2019 (Short-term effect)")) ( s4, label("Turnout November 2019 (Long-term effect)")) ///
 , keep (replacement) vertical yline(0) ylabel(-0.04(.04).2) xlabel("")  title ("Models without covariates") legend(position(6))  ytitle("ATE")

 graph copy g1
 
 
 ***************************
*MODELS WITH COVARIATES
***************************

logit  vote_2016 replacement   female age low_education high_educat i.employmentstatus  , 
margins, dydx( replacement) post
estimates store s1


logit  vote_ap    replacement  female age low_education high_educat i.employmentstatus  , 
margins, dydx(  replacement ) post
estimates store s2


logit   vote_may    replacement  female age low_education high_educat i.employmentstatus  , 
margins, dydx(   replacement ) post
estimates store s3



logit   vote_nov   replacement  female age low_education high_educat i.employmentstatus  , 
margins, dydx( replacement) post
estimates store s4


coefplot (s1 , label( "Turnout 2016 (Placebo)")) ( s2, label( "Turnout April 2019")) ///
 ( s3, label( "Turnout May 2019 (Short-term effect)")) ( s4, label("Turnout November 2019 (Long-term effect)")) ///
 , keep (replacement) vertical yline(0) ylabel(-0.04(.04).2) xlabel("")  title ("Models without covariates") legend(position(6))  ytitle("ATE")



  graph copy g2

 graph combine g1 g2, title("ATE Soft treated: Replacement Officers")  
 graph drop g1 g2
 

 
 
********************************************
* MATCHINGS
*****************************************

****************************
*******Matching 1
***************************

****APRIL****

teffects psmatch (  vote_april) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med)

estimates store s1

teffects psmatch ( vote_apr) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med) , nn(2)

estimates store s2

coefplot (s1, label(PSM Nearest Neighbor:1) ) (s2,  label(PSM Nearest Neighbor:2)) , vertical yline(0) xlabel( 1 " ") ytitle("ATE") title ("April 2019") ///
 legend(position (6) size(vsmall)) ylabel (-.08(.04).16)
 graph copy g1

****MAY****


teffects psmatch ( vote_may) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med)

estimates store s1

teffects psmatch  ( vote_may) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med),   nn(2)

estimates store s2


coefplot (s1, label(PSM Nearest Neighbor:1) ) (s2,  label(PSM Nearest Neighbor:2)) , vertical yline(0) xlabel( 1 " ") ytitle("ATE") title ("May 2019") ///
  legend(position (6) size(vsmall)) ylabel (-.08(.04).16)
 graph copy g2

****NOVEMBER


teffects psmatch  ( vote_nov) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med)

estimates store s1

teffects psmatch   ( vote_nov) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med),   nn(2)

estimates store s2

coefplot (s1, label(PSM Nearest Neighbor:1) ) (s2,  label(PSM Nearest Neighbor:2)) , vertical yline(0) xlabel( 1 " ") ytitle("ATE") title ("November 2019") ///
 legend(position (6) size(vsmall)) ylabel (-.08(.04).16)

graph copy g3


grc1leg  g1 g2 g3, legendfrom(g2) title ("Matching Estimates: Nearest Neighbor")

graph drop g1 g2 g3 

***************************
**Matching 2 
***************************


****APRIL****

teffects ipw ( vote_ap) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med)
estimates store s3


teffects aipw ( vote_ap) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med)
estimates store s4



coefplot  (s3,  label(Inv. Prob. Weighting)) ///
 (s4,  label (Augm. Inv. Prob. Weighting)) , vertical yline(0) xlabel( 1 " ") ytitle("ATE") title ("April 2019") ///
 legend(position (6) size(vsmall)) ylabel (-.08(.04).16)
 graph copy g1

****MAY****

teffects ipw ( vote_may) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med)
estimates store s3


teffects aipw  ( vote_may) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med)
estimates store s4

coefplot  (s3,  label(Inv. Prob. Weighting)) ///
 (s4,  label (Augm. Inv. Prob. Weighting)) , vertical yline(0) xlabel( 1 " ") ytitle("ATE") title ("May 2019") ///
  legend(position (6) size(vsmall)) ylabel (-.08(.04).16)
 graph copy g2
 
 
****NOVEMBER

teffects ipw  ( vote_nov) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med)
estimates store s3

teffects aipw  ( vote_nov) (treatment  female age low_education high_educat i.employmentstatus  income_high income_med)
estimates store s4
coefplot  (s3,  label(Inv. Prob. Weighting)) ///
 (s4,  label (Augm. Inv. Prob. Weighting)) , vertical yline(0) xlabel( 1 " ") ytitle("ATE") title ("November 2019") ///
 legend(position (6) size(vsmall)) ylabel (-.08(.04).16)

graph copy g3
grc1leg g1 g2 g3, legendfrom(g2) title ("Matching Estimates: Inverse Probability Weighting")
graph drop g1 g2 g3 






 *************************** 
*MODELS WITHOUT COVARIATES + TURNOUT 2016
***************************

est clear



logit vote_april  treatment    vote_2016  
margins, dydx(treatment) post
estimates store s2


logit   vote_may   treatment    vote_2016  
margins, dydx(treatment) post
estimates store s3



logit   vote_nov  treatment    vote_2016     
margins, dydx(treatment) post
estimates store s4


coefplot  ( s2, label( "Turnout April 2019")) ///
 ( s3, label( "Turnout May 2019 (Short-term effect)")) ( s4, label("Turnout November 2019 (Long-term effect)")) ///
 , keep ( treatment) vertical yline(0) ylabel(-0.04(.04).2)  xlabel("") title ("Models without covariates") legend(position(6))  ytitle("ATE") 

 graph copy g3
 

 ***************************
* MODELS WITH COVARIATES + TURNOUT 2016
***************************

 logit vote_april  treatment    vote_2016   female age low_education high_educat i.employmentstatus  , 


logit vote_april  treatment    vote_2016     female age low_education high_educat i.employmentstatus  , 
margins, dydx(treatment) post
estimates store s2


logit   vote_may   treatment    vote_2016    female age low_education high_educat i.employmentstatus  , 
margins, dydx(treatment) post
estimates store s3



logit   vote_nov  treatment    vote_2016       female age low_education high_educat i.employmentstatus  , 
margins, dydx(treatment) post
estimates store s4



coefplot( s2, label( "Turnout April 2019")) ///
 ( s3, label( "Turnout May 2019 (Short-term effect)")) ( s4, label("Turnout November 2019 (Long-term effect)")) ///
 , keep ( treatment) vertical yline(0) ylabel(-0.04(.04).2)  xlabel("") title ("Models without covariates") legend(position(6))  ytitle("ATE") 

 graph copy g4
 
 graph combine g3 g4
 
  graph drop  g3 g4
 

 
 ************************************
**Probability to vote in November
*************************************

reg prob_vote treatment
estimates store A
reg prob_vote  treatment  female age low_education high_educat i.employmentstatus  ,  
estimates store B
reg prob_vote  treatment vote_2016  female age low_education high_educat i.employmentstatus  ,  
estimates store C


coefplot  ( A, label( "Without covariates")) ///
 ( B, label( "With covariates")) ( C, label( "With covariates + Turnout 2016")) ///
 , keep (treatment) vertical yline(1) ylabel(0.6(.2)1.6) xlabel("")  title ("Probability to vote in repeated election (0-10)")  legend(position(6)) eform  ytitle("Marginal Effect")

 
 *******************
 ***TREATMENT EFFECTS ON NOVEMBER ATTITUDES
***************************

reg d_voteimp_nov  voteimp_w1 vote_2016 treatment female age i.education i.employmentstatus   , 
estimates store A
reg  d_voteduty_nov  voteduty_w1 vote_2016 treatment female age i.education i.employmentstatus   , 
estimates store B
reg  d_cleanelections_nov  cleanelections_w1 vote_2016 treatment female age i.education i.employmentstatus   , 
estimates store C
reg  d_trustparties_nov trustparties_w1 vote_2016 treatment female age i.education i.employmentstatus   , 
estimates store D
reg   d_votenotimp_nov  votenotimp_w1 vote_2016 treatment female age i.education i.employmentstatus   , 
estimates store E
reg  d_citizensimp_nov citizensimp_w1 vote_2016 treatment female age i.education i.employmentstatus   , 
estimates store F
coefplot  A, bylabel(Voting is important)  subtitle(, size(small))   ||  B, bylabel(Citizens are important in Spanish politics) || C , bylabel(Elections are not fraudulent) /// 
|| E, bylabel(Voting does not change anything)  ||  D, bylabel(Trust in political parties)    || F , bylabel(Voting is a duty) || ///
, keep( treatment) xline(0) ylabe(1 "ATE") level(95) xlabel (-.5 (0.5)1)

reg   d_freedomideas_nov   freedomideas_w1 vote_2016 treatment female age i.education i.employmentstatus   , 
estimates store G
reg  d_corruption_nov corruption_w1 vote_2016 treatment female age i.education i.employmentstatus   , 
estimates store H
reg  d_dontunderstandpolitics_nov dontunderstandpolitics_w1 vote_2016 treatment female age i.education i.employmentstatus   , 
estimates store I
reg  d_demonotworking_nov demonotworking_w1 vote_2016 treatment female age i.education i.employmentstatus   , 
estimates store J
reg  d_systnotworried_nov systnotworried_w1 vote_2016 treatment female age i.education i.employmentstatus   , 
estimates store K
coefplot  G, bylabel(All ideas should be freely expressed) subtitle(, size(small)) || H, bylabel(Corruption is pervasive) || I, bylabel(I don't understand most political issues) || ///
 J, bylabel(Democracy is not working well)  || K, bylabel(Political system does not care) ||  ///
, keep( treatment) xline(0) ylabe(1 "ATE") level(95) xlabel (-.5 (0.5)1)


 ***************
 *HETEROGENEOUS EFFECTS
 ***************+
 
 logit vote_may i.treatment##c.voteimp_w2  female age low_education high_educat i.employmentstatus  , 
 margins , dydx(treatment) at( voteimp_w2=(0(2)10)) 
 marginsplot, yline(0) xtitle("Voting is important") ytitle("Conditional Treatment Effect") title("")
 graph copy interaction1
  logit vote_may i.treatment##c.voteduty_w2   female age low_education high_educat i.employmentstatus  , 
 margins , dydx(treatment) at(voteduty_w2 =(0(2)10)) 
 marginsplot,  yline(0)  xtitle("Voting is a duty")  ytitle("Conditional Treatment Effect") title("")
 graph copy interaction2
 logit vote_may i.treatment##c.citizensimp_w2   female age low_education high_educat i.employmentstatus  , 
 margins , dydx(treatment) at(citizensimp_w2 =(0(2)10))  
  marginsplot, yline(0)  xtitle("Citizens are important in Spanish politics")  ytitle("Conditional Treatment Effect") title("")
  graph copy interaction3

 graph combine interaction1 interaction2 interaction3
 graph drop interaction1 interaction2 interaction3




***************************
* MEDIATION Y CONTROL 
***************************

medeff (logit vote_april  treatment  ) (logit vote_may   treatment vote_april ), mediate( vote_ap ) treat(treatment) sims(500) 

medeff (logit vote_april  treatment  ) (logit  vote_nov    treatment vote_april), mediate( vote_april) treat(treatment) sims(500) 






log close





















